<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
         var i=2;
        function doAdd(){
           
            var p=document.createElement("p");//创建p元素
            p.innerHTML="p"+i;//向p标签内部添加文本内容
            var div=document.querySelector("div");//获取p的父元素
            div.appendChild(p);
            i++;
        }
    </script>
</head>
<body>
    <input type="button" value="添加一行p" onclick="doAdd()">
    <div>
        <p>p1</p>
    </div>
</body>
</html>